package com.bajiao.app.controller.message;

import com.bajiao.app.base.AppBaseController;
import com.bajiao.common.api.vo.RestResult;
import com.bajiao.common.web.entity.TableDataInfo;
import com.bajiao.entity.industry.Industry;
import com.bajiao.entity.message.Message;
import com.bajiao.service.message.MessageService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

/**
 * @Description: 系统消息表
 * @Author: FanJq
 * @Date: 2024-10-22
 * @Version: V1.0
 */
@Slf4j
@Api(tags = "消息管理")
@RestController
@RequestMapping("/api/v1/message")
public class RestMessageController extends AppBaseController {

    @Resource
    private MessageService messageService;

    @GetMapping(value = "/page")
    @ApiOperation(value = "消息分页")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "pageNum", value = "页码", defaultValue = "1", dataType = "Integer", required = true),
            @ApiImplicitParam(name = "pageSize", value = "每页条数", defaultValue = "10", dataType = "Integer", required = true)
    })
    public RestResult<TableDataInfo<Message>> getMessagePage() {
        startPage();
        List<Message> messageList = messageService.getList();
        return success(getDataTable(messageList));
    }

    @GetMapping(value = "/details/{messageId}")
    @ApiOperation(value = "消息详情")
    public RestResult<Message> getMessageDetails(@PathVariable("messageId") String messageId) {
        Message message = messageService.getDetails(messageId);
        return success(message);
    }
}
